<style lang="less">
.lesson-item {
  border-radius: 5px;
  width: 100%;

  .img {
    border: 1px solid #ccc;
    border-radius: 5px;
    width: 100%;
    height: 120px;
    line-height: 120px;
    overflow: hidden;

    img {
        width: 100%;
        height: 100%;
    }
  }

  .title {
    width: 100%;
    height: 40px;
    line-height: 40px;
    text-align: center;
  }
}
</style>

<template>
  <div class="lesson-item" @click="handleLink(props.data.id)">
    <div class="img">
      <nut-image :src="cfg.imageUrl(props.data.thumb)" fit="fill" />
    </div>
    <div class="title">{{ props.data.title }}(￥{{ props.data.price }})</div>
  </div>
</template>

<script setup lang="ts">
import { useRouter } from 'vue-router'
import type { LessonListItem } from '@/config/types'
import cfg from '@/config/config'

interface Props {
  data: LessonListItem
}

const props = defineProps<Props>()
const router = useRouter()

const handleLink = (id: number) => {
  router.push({ name: 'lesson_detail', params: { id } })
}
</script>
